package vo

import (
	"dc-news/common/global/consts"
	"dc-news/common/utils"
	"dc-news/dao/model"
)

type AddCommentReq struct {
	NewsId         int    `json:"news_id"`
	ReplyCommentId int    `json:"reply_comment_id"`
	Content        string `json:"content"`
}

type LikeCommentReq struct {
	Likes int `json:"likes"`
}

type AddCommentResp struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
	Data struct {
		Id int `json:"id"`
	} `json:"data"`
}

type GetCommentResp struct {
	Code int           `json:"code"`
	Msg  string        `json:"msg"`
	Data model.Comment `json:"data"`
}

type GetCommentsResp struct {
	Code int             `json:"code"`
	Msg  string          `json:"msg"`
	Data []model.Comment `json:"data"`
}

type GetUserCommentListResp struct {
	Code       int    `json:"code"`
	Msg        string `json:"msg"`
	Pagination struct {
		Page  int `json:"page"`
		Limit int `json:"limit"`
		Total int `json:"total"`
	} `json:"pagination"`
	Data []model.UserComment `json:"data"`
}

func NewAddCommentResp(id int) *AddCommentResp {
	return &AddCommentResp{
		Code: consts.OKCode,
		Msg:  "ok",
		Data: struct {
			Id int `json:"id"`
		}{
			Id: id,
		},
	}
}

func NewGetCommentResp(comment *model.Comment) *GetCommentResp {
	return &GetCommentResp{
		Code: consts.OKCode,
		Msg:  "ok",
		Data: *comment,
	}
}

func NewGetCommentsResp(comments *[]model.Comment) *GetCommentsResp {
	return &GetCommentsResp{
		Code: consts.OKCode,
		Msg:  "ok",
		Data: *comments,
	}
}

func NewGetUserCommentListResp(comments *[]model.UserComment, p *utils.Pagination) *GetUserCommentListResp {
	return &GetUserCommentListResp{
		Code: consts.OKCode,
		Msg:  "ok",
		Pagination: struct {
			Page  int `json:"page"`
			Limit int `json:"limit"`
			Total int `json:"total"`
		}{
			Page:  p.Page,
			Limit: p.Size,
			Total: p.Total,
		},
		Data: *comments,
	}
}
